/*
 * Bloque.h
 *
 *  Created on: 13/04/2014
 *      Author: ariel
 */

#ifndef Bloque_H_
#define Bloque_H_
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#include "Elemento.h"
#include "../../physical_layer/Block.h"
#include "../entities/Twit.h"

class Bloque {

public:
	int id;
	int capacity;
	int tam_dispersion;
	vector<Elemento*> elements;

public:
	Bloque();
	Bloque(int, int);
	virtual ~Bloque();

	void addElemento(Elemento*);
	void deleteElemento(Elemento*);
	bool isFreed();
	bool isBusy();
	bool existElemento(Twit* registro);
	void duplicate_tamDispersion();
	void reducirMitad_tamDispersion();
	void markelements_asFree();
	void markElemento_asBusy(Elemento*);
	Elemento* getElemento(Twit* registro);
	void initializeelements_asFreed();

	friend ostream& operator<<(ostream &o, const Bloque &b);

	int getCapacity();
	void setCapacity(int capacity);

	int getId();
	void setId(int id);
	int getTamDispersion();
	void setTamDispersion(int tamDispersion);

	vector<Elemento*> getelements();
	void setelements(vector<Elemento*>);

	virtual std::string serialize();
	virtual void unserialize(std::string &buffer);
	virtual int getDataSize();
};

#endif /* Bloque_H_ */
